//
// Created by Administrator on 2021/11/4.
// May Saint Diana bless you!
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

class Solution {
public:
    int maxWidthOfVerticalArea(vector<vector<int>> &points) {
//        sort(points.begin(), points.end(), [](vector<int> &a, vector<int> &b) {
//            return a[0] < b[0];
//        });
        sort(points.begin(),points.end());
        int ans = 0;
        for (int i = 0; i < points.size() - 1; ++i) {
            ans = max(ans, points[i + 1][0] - points[i][0]);
        }
        return ans;
    }
    int maxWidthOfVerticalArea2(vector<vector<int>> &points) {
        set<int>s1;
        for(const auto &p:points){
            s1.insert(p[0]);
        }
        int ans = 0;
        vector<int>v(s1.begin(),s1.end());
        for (int i = 0; i < v.size()-1; ++i) {
            ans = max(ans,v[i+1]-v[i]);
        }
        return ans;
    }

};

int main() {
    vector<vector<int>> points{{3, 1},
                               {9, 0},
                               {1, 0},
                               {1, 4},
                               {5, 3},
                               {8, 8}};
    Solution solution;
    cout << solution.maxWidthOfVerticalArea2(points) << endl;
    return 0;
}
